package jmine.tec.persist.hibernate.initializer.domain;

import java.util.SortedMap;
import java.util.TreeMap;

import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.Sort;
import org.hibernate.annotations.SortType;

/**
 * @author wellington.santos
 * @created May 29, 2012
 */
@Entity
@DiscriminatorValue("1")
public class DiscriminatedChildEntity1 extends DiscriminatedParentEntity {

    private SortedMap<String, DiscriminatedParentEntity> map = new TreeMap<String, DiscriminatedParentEntity>();

    /**
     * @return map
     */
    @ManyToMany(fetch = FetchType.LAZY)
    @MapKey(columns = @Column(name = "CHAVE"))
    @JoinTable(name = "MAP_TABLE", joinColumns = @JoinColumn(name = "PAI_ID", nullable = false), inverseJoinColumns = @JoinColumn(name = "FILHO_ID", nullable = false))
    @Sort(type = SortType.NATURAL)
    public SortedMap<String, DiscriminatedParentEntity> getCollection() {
        return this.map;
    }

    /**
     * @param map map
     */
    public void setCollection(SortedMap<String, DiscriminatedParentEntity> map) {
        this.map = map;
    }

}
